import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { QuestionaireVO, QuestionaireForm, QuestionaireQuery } from '@/api/stroke/questionaire/types';

/**
 * 查询问卷列表
 * @param query
 * @returns {*}
 */

export const listQuestionaire = (query?: QuestionaireQuery): AxiosPromise<QuestionaireVO[]> => {
  return request({
    url: '/stroke/questionaire/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询问卷详细
 * @param id
 */
export const getQuestionaire = (id: string | number): AxiosPromise<QuestionaireVO> => {
  return request({
    url: '/stroke/questionaire/' + id,
    method: 'get'
  });
};

/**
 * 新增问卷
 * @param data
 */
export const addQuestionaire = (data: QuestionaireForm) => {
  return request({
    url: '/stroke/questionaire',
    method: 'post',
    data: data
  });
};

/**
 * 修改问卷
 * @param data
 */
export const updateQuestionaire = (data: QuestionaireForm) => {
  return request({
    url: '/stroke/questionaire',
    method: 'put',
    data: data
  });
};

/**
 * 删除问卷
 * @param id
 */
export const delQuestionaire = (id: string | number | Array<string | number>) => {
  return request({
    url: '/stroke/questionaire/' + id,
    method: 'delete'
  });
};
